package com.kuangstudy.thread.advanced;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author Losca
 * @date 2021/7/22 16:00
 */
public class TestPool {
    public static void main(String[] args) {
        //创建线程池
        ExecutorService service = Executors.newFixedThreadPool(10);
        //执行
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());
        //关闭
        service.shutdown();
        /*
        *   pool-1-thread-1
            pool-1-thread-4
            pool-1-thread-2
            pool-1-thread-3
            * */

    }
}

class MyThread implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }
}
